﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel.Composition;
using Microsoft.Practices.Prism.Regions;

namespace EIA.SLClient.ProjectManage
{
	/// <summary>
	/// LoadingView.xaml 的交互逻辑
	/// </summary>
    [Export]
	public partial class LoadingView : UserControl, SimpleMvvmToolkit.INotifyable
	{
		public LoadingView()
		{
			this.InitializeComponent();
            SimpleMvvmToolkit.MessageBus.Default.Register(EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.BUSY_STATE, this);
		}

        [Import]
        public IRegionManager RegionManager{get;set;}

        public void Notify(string token, object sender, SimpleMvvmToolkit.NotificationEventArgs e)
        {
            switch (token)
            {
                case EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.BUSY_STATE:
                    if (e is SimpleMvvmToolkit.NotificationEventArgs<bool>)
                    {
                        SimpleMvvmToolkit.NotificationEventArgs<bool> be = e as SimpleMvvmToolkit.NotificationEventArgs<bool>;
                        if (be.Data) RegionManager.RequestNavigate(EIA.SLClient.ProjectManage.Infrastructure.RegionNames.OverlayRegion, this.GetType().FullName);
                    }
                    break;
            }
        }
    }
}